package com.dyh.quickdemozwei.stg;

public class ParamShift {

    public interface Foo1{
         Object foo1(String s1,Integer i1);
    }

    public interface Foo2{
        Object foo2(String s1,Integer i1,Double d1);
    }

    public interface Foo3{
        Object foo3(Long l);
    }

    public static class FooSink implements Foo1,Foo2,Foo3{


        @Override
        public Object foo1(String s1, Integer i1) {
            return foo$(s1,i1);
        }

        @Override
        public Object foo2(String s1, Integer i1, Double d1) {
            return foo$(s1,i1,d1);
        }

        @Override
        public Object foo3(Long l) {
//            return foo$("-",1,0,l);//n: Cannot cast java.lang.Integer to java.lang.Double
            return foo$("-",1,0d,l);
        }

        public Object foo$(Object...args){

            String s1 =  (String) args[0];
            Integer i1 = (Integer) args[1];


//            Double d1 = args.length>=3?(Double) args[2]:null;
//            Long l1 =  args.length>=4?(Long) args[3]:null;
            Double d1 = softArgGet(2,args,Double.class);
            Long l1 =  softArgGet(3,args,Long.class);

            System.out.println(s1);
            System.out.println(i1);
            System.out.println(d1);
            System.out.println(l1);

            return "ok";
        }

        /*非必填*/
        public static <T> T softArgGet(int idx,Object[] args,Class<T> cls){
            return args.length-1>=idx? cls.cast(args[idx]) : null;
        }

    }


    public static void main(String[] args) {
        int i= 1;
        int[] arr={0,1,2,3,4,5};
        for (i++;i<arr.length;i++){
            System.out.println(arr[i]);
        }
    }
//    public static void main(String[] args) {
//        FooSink fooSink = new FooSink();
//
//        fooSink.foo1("1",1);
//
//        System.out.println("==========");
//
//        fooSink.foo2("1",1,2.3d);
//
//        System.out.println("==========");
//
//        fooSink.foo3(123123L);
//
//    }
}
